<?php
namespace App\Services\Company\Company;

use App\Models\Company\Company;
use App\Models\Agent\Agent;


class CompanyLogic
{
    // 添加公司
    public function addCompany($data)
    {
        $rst = Company::create(['company_name' => $data['company_name'], 'phone_name' => $data['phone_name'],
            'address' => $data['address'], 'phone' => $data['phone'], 'code' => $data['code'],
            'company_image' => $data['company_image']]);
        return auto_return(['id' => $rst],'添加成功！');
    }

    //公司列表
    public function companyList(){
        $res = Company::orderBy('id','asc')->paginate(10);
        return auto_return($res,'成功！');
    }

    //公司详情
    public function companyDetail($data){
        $res = Company::where('id', $data['id'])->first();
        return auto_return($res,'成功!');
    }

    //修改公司内容
    public function updateCompany($data){
        unset($data['file']);
        unset($data['token']);
        $res = Company::where('id', $data['id'])->update($data);
        return auto_return($res,'成功!');
    }
   
}